<?php

$system = [

    //访问白名单
    'allow_ips' => ['127.0.0.1'],

    //系统菜单
    'sys_menu' => [
        ['title' => '系统', 'url' => '', 'son' => [
            ['title' => '系统配置', 'url' => '/admin/config/system', 'id' => 'config_system', 'son' => [
                ['title' => '修改配置', 'url' => '/admin/config/setting', 'id' => 'config_setting']
            ]],
            ['title' => '缓存清理', 'url' => '/admin/config/cache', 'id' => 'config_cache', 'has_line' => 1],
			['title' => '部门管理', 'url' => '/admin/depart/index', 'id' => 'depart_index', 'son' => [
                ['title' => '列表数据',  'url' => '/admin/depart/datalists', 'id' => 'depart_datalists'],
                ['title' => '新增&编辑', 'url' => '/admin/depart/save', 'id' => 'depart_save'],
                ['title' => '保存数据',  'url' => '/admin/depart/savedata', 'id' => 'depart_savedata'],
                ['title' => '删除数据',  'url' => '/admin/depart/delete', 'id' => 'depart_delete']
            ]],
			['title' => '职员管理', 'url' => '/admin/worker/index', 'has_line' => 1 , 'id' => 'worker_index', 'son' => [
                ['title' => '列表数据', 'url' => '/admin/worker/datalist', 'id' => 'worker_datalist'],
                ['title' => '新增&编辑', 'url' => '/admin/worker/save', 'id' => 'worker_save'],
                ['title' => '保存数据', 'url' => '/admin/worker/savedata', 'id' => 'worker_savedata'],
                ['title' => '删除数据', 'url' => '/admin/worker/delete', 'id' => 'worker_delete']
            ]],

			['title' => '应用商店', 'url' => '/admin/appin/shop', 'id' => 'appin_shop'],

			['title' => '已装应用', 'url' => '/admin/appin/installed', 'id' => 'appin_installed'],

			['title' => '本地应用', 'url' => '/admin/appin/localapp', 'id' => 'appin_localapp', 'son' => [
                ['title' => '安装应用', 'url' => '/admin/appin/install', 'id' => 'appin_install']
            ]]
        ]]
    ],
    'cache_tag' => [
        'system' => '全部缓存'
    ]
];

$allAppin = \app\appin\service\Package::allAppin();
$countAppins = count($allAppin);
if ( $countAppins > 0 ) {
    $app_sys_menu = [];
    $cache_tag_arr = [];
    for ( $i = 0; $i < $countAppins; $i++ ) {
        $config =  \app\appin\service\Package::load($allAppin[$i]);
        $app_sys_menu[] = ['title' => $config['name'], 'url' => '', 'son' => $config['system_menu']];
        if (isset($config['cache_tag'])) {
            $cache_tag_arr = array_merge($cache_tag_arr, $config['cache_tag']);
        }
    }
    $system['sys_menu'] = array_merge($system['sys_menu'], $app_sys_menu);
    $system['cache_tag'] = array_merge($system['cache_tag'], $cache_tag_arr);
}
return $system;
